package com.twu.biblioteca;

/**
 * Created by sravanns on 19/06/14.
 */
public class Movie {
    private String name;
    private int year;
    private String director;
    private int rating;

    public Movie(String name,int year,String director,int rating) {
        this.name = name;
        this.year=year;
        this.director=director;
        this.rating=rating;
    }

    @Override
    public String toString() {
        return
                "\nNAME: " + name  +
                " YEAR: " + year +
                " DIRECTOR: " + director+
                " RATING: " + rating ;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Movie movie = (Movie) o;

        if (rating != movie.rating) return false;
        if (year != movie.year) return false;
        if (director != null ? !director.equals(movie.director) : movie.director != null) return false;
        if (name != null ? !name.equals(movie.name) : movie.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + year;
        result = 31 * result + (director != null ? director.hashCode() : 0);
        result = 31 * result + rating;
        return result;
    }

    public String getMovieName() {
        return name;
    }
}
